package com.yl.auth.service.impl;

import com.alibaba.excel.EasyExcel;
import com.yl.auth.easyexcel.listener.ExcelDanganguanliListener;
import com.yl.auth.model.entity.Danganguanli;
import com.yl.auth.mapper.DanganguanliMapper;
import com.yl.auth.service.DanganguanliService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.InputStream;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yl
 * @since 2023-06-17
 */
@Slf4j
@Service
public class DanganguanliServiceImpl extends ServiceImpl<DanganguanliMapper, Danganguanli> implements DanganguanliService {

    @Resource
    private DanganguanliMapper danganguanliMapper;

    @Override
    public void importData(InputStream inputStream) {
        //这里需要指定读用哪个class去读，然后读取第一个sheet文件流会自动关闭
        EasyExcel.read(inputStream,Danganguanli.class,new ExcelDanganguanliListener(baseMapper)).sheet().doRead();
        log.info("importData finished");
    }
}
